import queryString from 'query-string';
// 车型库首页
export const getModelsUrl = ({
  language,
  brandSlug,
  modelSlug,
  trimSlug,
  specSlug,
  searchParams
}:{
  language: string
  brandSlug?: string
  modelSlug?: string
  trimSlug?: string
  specSlug?: string
  searchParams?: {
    brand?: string
    model?: string
    fuelType?: string
    bodyType?: string
    minPrice?: number
    maxPrice?: number
  }
})=>{
  if(specSlug){ // 车系规格详情页
    return `/${language}/models/${brandSlug}/${modelSlug}/${trimSlug}/${specSlug}`
  }
  if(trimSlug){ // 车系
    return `/${language}/models/${brandSlug}/${modelSlug}/${trimSlug}`
  }
  if(modelSlug){ // 车型
    return `/${language}/models/${brandSlug}/${modelSlug}`
  }
  if(brandSlug){ // 品牌
    return `/${language}/models/${brandSlug}`
  }
  if(searchParams){ // 筛选参数
    // 使用 query-string 库来构建查询字符串
    const params = queryString.stringify(searchParams)
    return `/${language}/models?${params}`
  }
  return `/${language}/models` // 车型库首页
}

